<div class="shelf-form">
  <div class="panel-header">
    <div class="header-icon-wrapper">
      <i class="pi pi-pencil header-icon"></i>
    </div>
    <div class="header-text">
      <h2 class="panel-title">Edit Shelf</h2>
      <p class="panel-description">
        Customize your shelf name and icon
      </p>
    </div>
    <p-button
      icon="pi pi-times"
      [text]="true"
      [rounded]="true"
      severity="secondary"
      (onClick)="closeDialog()"
      styleClass="close-button">
    </p-button>
  </div>

  <div class="shelf-container">
    <div class="shelf-fields">
      <div class="shelf-row">
        <label class="label">Shelf Name:</label>
        <input type="text" pInputText [(ngModel)]="shelfName" placeholder="Enter shelf name..." class="input"/>
      </div>

      <div class="shelf-row">
        <label class="label">Shelf Icon:</label>
        <div class="icon-section">
          @if (!selectedIcon) {
            <p-button label="Select Icon" icon="pi pi-search" [outlined]="true" severity="info" (onClick)="openIconPicker()"></p-button>
          }

          @if (selectedIcon) {
            <div class="icon-container">
              <div class="icon-wrapper">
                <app-icon-display
                  [icon]="selectedIcon"
                  size="24px"
                  iconClass="icon"
                />
              </div>
              <p-button icon="pi pi-times" (onClick)="clearSelectedIcon()" [rounded]="true" [text]="true" severity="danger"></p-button>
            </div>
          }
        </div>
      </div>
    </div>
  </div>

  <div class="dialog-footer">
    <div></div>
    <div class="footer-actions">
      <p-button
        label="Cancel"
        severity="secondary"
        [outlined]="true"
        (onClick)="closeDialog()"
      />
      <p-button
        label="Save Changes"
        icon="pi pi-check"
        severity="success"
        (onClick)="save()"
      />
    </div>
  </div>
</div>
